<?php
/* Displays the selected Client with editable text fields. Any changes that are 
 * made will be saved to that Client. Empty fields will not overwrite existing 
 * field values. Data will be sanitized to prevent bad things.
 * @AUTHOR: Nicolas DaLomba
 */

        session_start();
        session_cache_expire(30);
        include_once('database/dbClient.php');
        include_once('domain/Client.php');
        
        // First it checks to see if the client exists in the database.
        $id = str_replace("_"," ",$_GET["id"]);
        $client = retrieve_client($id);
        if (!$client) {
            echo('<p id="error">Error: there\'s no client with this id in the database</p>' . $id);
            die();
?>
<html>
    <head>
        <title>
            Edit Client <?PHP echo($client->get_first_name() . " " . $client->get_last_name()); ?>
        </title>
        <link rel="stylesheet" href="styles.css" type="text/css" />
    </head>
    <body>
        <div id="container">
            <?PHP include('header.php'); ?>
                <div id="content">
                    <?PHP
                        if ($_POST['_form_submit'] != 1)
                         //in this case, the form has not been submitted, so show it
                        include('editClient.inc');
                        include('footer.inc');                                
                    ?>
            
                        </div>
                        <?PHP include('footer.inc');?>
                </div>
        </body>
</html>
